package contents.entities;

import java.util.Comparator;

public class Subject {
    public static class ByNameAndYearClassComparator implements Comparator {
        public int compare(Object object1, Object object2) {
            Subject subject1 = (Subject) object1;
            Subject subject2 = (Subject) object2;
            
            if (subject1.getName().equals(subject2.getName())) {
                return subject1.getYearClass().compareTo(subject2.getYearClass());
            } else {
                return subject1.getName().compareTo(subject2.getName());
            }
        }   
    }
    
    private int subjectId;
    private String name;
    private Integer yearClass;
    
    public Subject(int subjectId, String name, Integer yearClass) {
        this.subjectId = subjectId;
        this.name = name;
        this.yearClass = yearClass;
    }
    
    public int getSubjectId() {
        return subjectId;
    }

    public String getName() {
        return name;
    }
    
    public Integer getYearClass() {
        return yearClass;
    }
    
    public String getFullName() {
        return name + "(" + yearClass + ")";
    }

    /*
     * For purpose of web service.
     */
    public void setName(String name) {
        this.name = name;
    }

    /*
     * For purpose of web service.
     */
    public void setSubjectId(int subjectId) {
        this.subjectId = subjectId;
    }

    /*
     * For purpose of web service.
     */
    public void setYearClass(Integer yearClass) {
        this.yearClass = yearClass;
    }
}
